﻿using System;
using System.Globalization;
using System.Xml.Serialization;

namespace FulcrumApi.entities
{
    [Serializable, XmlRoot("project")]
	public class Project
	{
		[XmlIgnore]
        public DateTime CreatedAt { get; set; }

        [XmlElement("created-at")]
        public string CreatedAtFormatted
        {
            get { return CreatedAt.ToString("yyyy/dd/yyTHH:mm:ssZ", CultureInfo.InvariantCulture); }
            //set { CreatedAt = DateTime.ParseExact(value.Replace("Z", ""), "s", CultureInfo.InvariantCulture); }
            set { CreatedAt = DateTime.Parse(value); }
        }

	    [XmlElement("default-velocity")]
	    public int DefaultVelocity { get; set; }

	    [XmlElement("id")]
	    public int Id { get; set; }


        [XmlElement("iteration-length")]
        public int IterationLength { get; set; }

	    [XmlElement("iteration-start-day")]
	    public int IterationStartDay { get; set; }

        [XmlElement("name")]
	    public String Name;

        [XmlElement("point-scale")]
        public String PointScale;

        [XmlIgnore]
        public DateTime UpdatedAt { get; set; }

        [XmlElement("updated-at")]
        public string UpdatedAtFormatted
        {
            get { return UpdatedAt.ToString("yyyy/dd/yyTHH:mm:ssZ", CultureInfo.InvariantCulture); }
            set { UpdatedAt = DateTime.Parse(value); }
        }

        [XmlIgnore]
        public DateTime StartDate { get; set; }

        [XmlElement("start-date")]
        public string StartDateFormatted
        {
            get { return StartDate.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture); }
            set { StartDate = DateTime.ParseExact(value, "yyyy-MM-dd", CultureInfo.InvariantCulture); }
        }
	}
}
